The present invention relates to a registration device that registers an ID code.
A vehicle may be provided with an electronic key system that verifies an ID code transmitted from an electronic key. Japanese Laid-Open Patent Publication No. 2012-193571 describes an electronic key system that includes a main key and a registration device, which registers ID codes of sub-keys.
In the '571 publication, a maximum number of ID codes that can be registered is set for the electronic key system. To register a new ID code to the registration device when the maximum number of ID codes has already been registered, the new ID code is overwritten over an old registered ID code. When the overwriting of the new ID code is interrupted by, for example, a momentary power outage, the new ID code cannot be registered. In addition, the old ID code is deleted and erased.
It is an object of the present invention to provide a registration device that holds the correct ID code when an unexpected registration interruption occurs.
One aspect of the present invention is a registration device for registering ID codes. The registration device includes a storage unit set to allow for registration of a maximum of an n number of ID codes, where n is a natural number of two or greater. A registration control unit registers ID codes to the storage unit. The storage unit includes an n+1 number of ID code storage regions, each of which stores an ID code. A management data storage region stores management data indicating whether the ID code of each ID code storage region is valid or invalid. The registration control unit includes instructions configured to write an input ID code to an invalid ID code storage region among the n+1 number of ID code storage regions in accordance with the management data, update the management data after the input ID code is written to validate the invalid ID code storage region to which the input ID code has been written, and update the management data, when an ID code is stored in each of the n+1 number of ID code storage regions after the input ID code is written, to invalidate at least one ID code storage region excluding the invalid ID code storage region to which the input ID code has been written.
Other aspects and advantages of the present invention will become apparent from the following description, taken in conjunction with the accompanying drawings, illustrating by way of example the principles of the invention.